home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 10 / FM Towns Free Software Collection 10.iso / ms_dos / tool / fapxtool / src / txl / txllog2.c < prev    next >
C/C++ Source or Header  |  1995-02-12  |  8KB  |  361 lines

  1. /***************
  2. *
  3. * g:\exe\txl\src\txllog2.c
  4. */
  5. #include "txl.h"
  6.  
  7. /* 0x8146 == ':' */
  8. #define W_COLON        (0x8146)
  9. /* 0x8183 == '<' / LTS = less than sign */
  10. #define W_LTS        (0x8183)
  11.  
  12. int get_hpstyle(char *id, int org)
  13. {
  14.     int style = org;
  15.     FILE *fp;
  16.     char *token;
  17.     char *buf = logstr_mlist;    /* 80バイト---使い回し(^^;) */
  18.     unsigned char atmp[2] = {0,0};
  19.     int ret;
  20.  
  21.     if ((fp = fopen(txfsetfile, "rt")) == NULL) {
  22.         return (style);    /* myforum.logは存在しない */
  23.     }
  24.     while (!feof(fp)) {
  25.         fgets(buf, 80, fp);
  26.         if ((token = strchr(buf, '\n')) != NULL) {
  27.             *token = NUL;
  28.         }
  29.         if (*buf == '%') {
  30.             if (strncmp(id, buf + 1, 8) == 0) {
  31.                 token = strchr(buf+9, '=');
  32.                 if (token != NULL) {
  33.                     ret = sscanf(token+1, "%d,%2c", &style, atmp);
  34.                     if (ret >= 2) {
  35.                         if (atmp[1]) {
  36.                             log_hpchr = atmp[0] << 8 | atmp[1];
  37.                         }
  38.                         else {
  39.                             log_hpchr = atmp[0];
  40.                         }
  41.                     }
  42.                     style &= 1;        /* 第0ビット以外無視 */
  43.                 }
  44.                 break;
  45.             }
  46.         }
  47.     }
  48.     return (style);
  49. }
  50.  
  51. void log_sethptitle()
  52. {
  53.     int i, type = CT_ANK;
  54.     unsigned char sepchr[3] = {0, 0, 0};
  55.     char *tmp;
  56.  
  57.     if ((log_hpchr & 0x0ff00) == 0) {
  58.         sepchr[0] = log_hpchr & 0x0ff;
  59.     }
  60.     else {
  61.         sepchr[0] = (log_hpchr >> 8) & 0x0ff;
  62.         sepchr[1] = log_hpchr & 0x0ff;
  63.     }
  64.  
  65.     tmp = strchr(log_bufptr, 0x0d);
  66.     if (tmp != NULL) {
  67.         *tmp = NUL;            /* ログファイルに傷を付ける(行末をNULに) */
  68.     }
  69.  
  70.     if ((tmp = jstrchr(log_bufptr, log_hpchr)) != NULL) {
  71.         *tmp = NUL;        /* ログファイルに傷を付ける(境界をNULに) */
  72.         tmp++;
  73.         if (log_hpchr & 0x0ff00) {
  74.             tmp++;
  75.         }
  76.         if (log_hpstyle == 1) {
  77.             strcpy(log_rhandle, log_bufptr);    /* 前半からハンドル取得 */
  78.             log_bufptr = tmp;
  79.         }
  80.         else {
  81.             strcpy(log_rhandle, tmp);            /* 後半からハンドル取得 */
  82.         }
  83.     }
  84.     get_titlestr();
  85.     if (log_hpstyle == 1) {
  86.         sprintf(line1, "%s%s%s", log_handle, sepchr, log_titlestr);
  87.     }
  88.     else {
  89.         sprintf(line1, "%s%s%s", log_titlestr, sepchr, log_handle);
  90.     }
  91.  
  92.     for (i = 0; i < 41; i++) {
  93.         if (*(line1 + i) == NUL) {
  94.             break;
  95.         }
  96.         type = chkctype(*(line1 + i), type);
  97.     }
  98.     if (i > 40) {
  99.         if (type != CT_KJ2) {
  100.             *(line1 + 40) = NUL;
  101.         }
  102.         else {
  103.             *(line1 + 39) = NUL;
  104.         }
  105.     }
  106.     strcpy(log_titlestr, line1);
  107. }
  108.  
  109. void hpchk()
  110. {
  111.     char *handle;
  112.  
  113.     if ((handle = getenv("TXFUSER")) != NULL) {
  114.         strncpy(log_handle, handle, 16);
  115.     }
  116.  
  117.     /*  option for CATBEE  */
  118.     if (jstrstr(log_handle, "猫飛") != NULL) {
  119.         strcpy(log_handle, "CATBEE");
  120.     }
  121.     /*  End of CATBEE option  */
  122.  
  123.     strncpy(log_reply, log_bufptr, 3);
  124.     log_reply[3] = 0;
  125.     log_bufptr += 23;
  126.     strncpy(log_resp, log_bufptr, 8);
  127.     log_resp[8] = 0;
  128.     log_bufptr += 14;
  129.     log_hpstyle = get_hpstyle(log_idstr, log_hpstyle);
  130.  
  131.     if (log_hpchr == 0) {
  132.         if (log_hpstyle == 1) {
  133.             log_hpchr = W_COLON;
  134.         }
  135.         else {
  136.             log_hpchr = W_LTS;
  137.         }
  138.     }
  139.  
  140.     if (log_hpstyle >= 0) {
  141.         log_sethptitle();
  142.     }
  143.     else {
  144.         get_titlestr();
  145.     }
  146.  
  147.     fprintf(fpmes, "hp=%s;reply=%s;resp=%s;handle=%s;title=%s\n",
  148.             log_idstr, log_reply, log_resp, log_rhandle, log_titlestr);
  149.  
  150. }
  151.  
  152. void mailchk(int style)
  153. {
  154. /*
  155.  2  山田 弘明     PEE01244  05/17 10:21
  156.  2  山田 弘明     PEE01244          93/05/17 10:21
  157.     題名:FAPX406B.LZH
  158.  6  -              PCV>ZZZ99999 04/01 07:29
  159.     題名:PC-VANからのテストだよ~ん
  160. */
  161.     if ((style == 7)||(style == 13)) { /* 標準mail or newmail */
  162.         strncpy(log_rhandle, log_bufptr + 4, 16);
  163.         del_tailspace(log_rhandle, 15);
  164. #if 0
  165.         for (i = 15; i > 0; i--) {
  166.             if (*(log_rhandle + i) == 0x20) {
  167.                 *(log_rhandle + i) = NUL;
  168.             }
  169.             else if ((*(log_rhandle + i) == 0x40) && 
  170.                     (*(log_rhandle + i - 1) == 0x81)) { /* 全角スペース    */
  171.                 i--;
  172.                 *(log_rhandle + i) = NUL;
  173.             }
  174.             else {
  175.                 break;
  176.             }
  177.         }
  178. #endif
  179.         log_bufptr += 22;
  180.         strncpy(log_idstr, log_bufptr, 8);
  181.         log_idstr[8] = NUL;
  182.     }
  183.     else { /* mail from PC-VAN */
  184. /*
  185. 10  -              PCV>***%%%%% %%/%% %%:%%
  186. 15  -                 PCV>***%%%%%      %%/%%/%% %%:%%
  187. ↑スタイル             ~~~
  188. */
  189.         log_bufptr += 19;
  190.         if (style == 15) {
  191.             log_bufptr += 3;
  192.         }
  193.         strncpy(log_idstr, log_bufptr, 12);
  194.         log_idstr[12] = NUL;
  195.     }
  196.  
  197.     if ((log_bufptr = strchr(log_bufptr, 0x0a)) == NULL) {
  198.         fprintf(fpmes, "Error:find EOF before title+1 line");
  199.         Exit(1);
  200.     }
  201.     log_bufptr += 11;
  202.     get_titlestr();
  203.     fprintf(fpmes, "mail=%s;handle=%s;title=%s\n", log_idstr, log_rhandle, log_titlestr);
  204.  
  205. }
  206.  
  207. void widegatechk()
  208. {
  209. /*
  210. -------------------------------------------------------------------------------
  211.  4  WIDE GATE         WID00100  03/22 09:19
  212.     題名:MAIL from WIDE for FAPX
  213.  
  214. Date: Mon, 22 Mar 93 08:56:23 JST
  215. From: PFG02442@niftyserve.or.jp
  216. From: Kouichi Shiono <shiono@cms20x.niftyserve.or.jp>
  217. From: oza@cmlab.densi.kansai-u.ac.jp (Kouji Ozaki)
  218. From: goichi <goichi@joho.densi.kansai-u.ac.jp>
  219. From: morikawa@sunkist.tis.co.jp (Masahiko Morikawa )
  220. From: Kazutaka Suzuki <suzuki@iecs.kansai-u.ac.jp>
  221. From: takada@enzan.ee.kansai-u.ac.jp (Hideo Takada)
  222. From: joo@cia.ncl.omron.co.jp (Naoki Joo)
  223. From: tatsu@nxenzan.ee.kansai-u.ac.jp (Tatsuaki Yunoki)
  224. From: naka@cms101.niftyserve.or.jp (Tomohiko Nakatani)
  225. From: 荒木 聖 <HAD01045@niftyserve.or.jp>
  226. From: Kazutaka Suzuki (鈴木  和貴) <suzuki@iecs.kansai-u.ac.jp>
  227. From: "maruu(Ushioda)" <PEA03643@niftyserve.or.jp>
  228. To: PEE01244@niftyserve.or.jp
  229. Cc: PDB02377@niftyserve.or.jp
  230. -------------------------------------------------------------------------------
  231. */
  232.  
  233.     int i;
  234.     char *tmpptr, *tmpptr2, *inetid;
  235.     if ((log_bufptr = strchr(log_bufptr, 0x0a)) == NULL) {
  236.         fprintf(fpmes, "Error:find EOF before title+1 line");
  237.         Exit(1);
  238.     }
  239.     log_bufptr += 11;
  240.     get_titlestr();
  241.     for (i = 2; i < 5; i++) {
  242.         if ((log_bufptr = strchr(log_bufptr+1, 0x0a)) == NULL) {
  243.             fprintf(fpmes, "Error:find EOF before title+%d line", i);
  244.             Exit(1);
  245.         }
  246.     }
  247.     log_bufptr += 7;
  248.     inetid = malloc(80);
  249.     if (inetid == NULL) {
  250.         fprintf(stderr, "TXL: out of memory(widegatechk)\n");
  251.         Exit(1);
  252.     }
  253.     tmpptr = inetid;
  254.  
  255.     for (i = 0; ((*(tmpptr++) = *(log_bufptr++)) != '\r') && (i < 80); i++);
  256.     inetid[i] = NUL;
  257.     while (strchr(inetid, ' ') != NULL) {
  258.         if ((tmpptr = jstrchr(inetid, '@')) == NULL) {
  259.             break;        /* anything illegal!! */
  260.         }
  261.         if ((tmpptr2 = strchr(tmpptr, ' ')) != NULL) {
  262.             *tmpptr2 = NUL;
  263.         }
  264.         else {
  265.             while ((*tmpptr != ' ') && (*tmpptr != '<')) tmpptr--;
  266.             tmpptr2 = inetid;
  267.             do {
  268.                 *(tmpptr2++) = *(++tmpptr);
  269.             } while ((*tmpptr != NUL) && (*tmpptr != '>'));
  270.             if (*(--tmpptr2) == '>') {
  271.                 *tmpptr2 = NUL;
  272.             }
  273.         }
  274.     }
  275.  
  276.     fprintf(fpmes, "wpnc=%s;title=%s\n", inetid, log_titlestr);
  277.     free(inetid);
  278. }
  279.  
  280. void maillistchk()
  281. {
  282. /*
  283.   1   **********   04/08  B NEWSARA.LZH 未だできんんんんんんん      ILDFTINC
  284. */
  285.     strncpy(log_rhandle, log_bufptr + 6, 16);
  286.     del_tailspace(log_rhandle, 15);
  287.     log_bufptr += 31;
  288.     get_titlestr();
  289.     log_titlestr[40] = NUL;
  290.     del_tailspace(log_titlestr, 39);
  291.     log_bufptr += 40;
  292.     strncpy(log_idstr, log_bufptr, 8);
  293.     log_idstr[8] = NUL;
  294.     fprintf(fpmes, "mailid=%s;handle=%s;title=%s\n", log_idstr, log_rhandle, log_titlestr);
  295. }
  296.  
  297. void fgalchk()
  298. {
  299. /* 特殊処理が必要なフォーラム
  300.   LM FGALM    AN FGALIAN
  301.   W1 FGALSW1  W2 FGALSW2
  302.   AY FGALRAY
  303. AG  3  126 HCD00632 94/02/28   27059 B IZUMI012.LZH MAG:リレハンメルの女の子
  304. */
  305.     int lib;
  306.     char tail[4];
  307.  
  308.     strncpy(tail, log_bufptr, 2);
  309.     tail[2] = NUL;
  310.     switch (*(unsigned int *)tail) {
  311. #ifdef LSI_C
  312.     case 'ML':
  313. #else
  314.     case 0x4d4c:
  315. #endif
  316.         strcpy(tail, "M");
  317.         break;
  318. #ifdef LSI_C
  319.     case 'NA':
  320. #else
  321.     case 0x4e41:
  322. #endif
  323.         strcpy(tail, "IAN");
  324.         break;
  325. #ifdef LSI_C
  326.     case '1W':
  327. #else
  328.     case 0x3157:
  329. #endif
  330.         strcpy(tail, "SW1");
  331.         break;
  332. #ifdef LSI_C
  333.     case '2W':
  334. #else
  335.     case 0x3257:
  336. #endif
  337.         strcpy(tail, "SW2");
  338.         break;
  339. #ifdef LSI_C
  340.     case 'YA':
  341. #else
  342.     case 0x5941:
  343. #endif
  344.         strcpy(tail, "RAY");
  345.         break;
  346.     }
  347.     sscanf(log_bufptr+2, "%d %d", &lib, &log_downno);
  348.     strncpy(log_resp, log_bufptr + 11, 8);
  349.     log_resp[8] = NUL;
  350.  
  351.     log_bufptr += 39;
  352.     get_downname();
  353.     strcpy(log_docfile, log_downname);
  354.     if (strchr(log_docfile, '.')) {
  355.         strcpy(strchr(log_docfile, '.'), ".GGG");
  356.     }
  357.     fprintf(fpmes, "forum=FGAL%s;libno=%d;datano=%d;resp=%s;docfile=%s;datafile=%s;\n"
  358.     ,tail, lib, log_downno, log_resp, log_docfile, log_downname);
  359. }
  360.  
  361.